<template>
  <div>
    <el-form :inline="true" @submit.native.prevent>
      <el-form-item label="搜索">
        <el-input v-model="search" placeholder="请输入手机号" @keyup.enter="handleSearch" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="handleSearch">搜索</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="table.loading" :data="table.data" border>
      <el-table-column label="手机号" prop="expert.mobile" />
      <el-table-column label="姓名" prop="name" />
      <el-table-column label="位次" prop="rank" />
      <el-table-column label="添加时间" prop="created_at" />
      <el-table-column label="操作">
        <template slot-scope="props">
          <el-button type="primary" @click="handleView(props.row)">详情</el-button>
        </template>
      </el-table-column>
    </el-table>
    <WrapPagination>
      <el-pagination
        class="pagination"
        :current-page="table.page"
        :page-sizes="$store.state.app.pagination.sizes"
        :page-size="table.size"
        :layout="$store.state.app.pagination.layout"
        :total="table.total"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </WrapPagination>
  </div>
</template>

<script>
import { TableMixin } from '../../../components/mixin'
import { getList } from '../../../api/query-log'

export default {
  name: 'Index',
  mixins: [TableMixin],
  data() {
    return {
      search: ''
    }
  },
  mounted() {
    this.getList()
  },
  methods: {
    getList() {
      this.wrapResourceList(getList, {
        search: this.search
      })
    },
    handleSearch() {
      this.table.page = 1
      this.getList()
    },
    handleView(row) {
      this.$router.push({
        name: 'generate-log-detail',
        params: {
          id: row.id
        }
      })
    }
  }
}
</script>

<style scoped>

</style>
